home *** CD-ROM | disk | FTP | other *** search
- program TstHshLP;
-
- uses
- SysUtils,
- HashLinP in 'HashLinP.pas';
-
- const
- ElementCount = 53;
-
- function CalcELFHash(const S : string) : longint; far;
- var
- G : longint;
- i : integer;
- begin
- Result := 0;
- for i := 1 to length(S) do begin
- Result := (Result shl 4) + ord(S[i]);
- G := Result and $F0000000;
- if (G <> 0) then
- Result := Result xor (G shr 24);
- Result := Result and (not G);
- end;
- end;
-
- const
- TPEmployees : array [0..32] of string[15] =
- ('Antypas', 'Bolduc', 'Brady',
- 'Bucknall', 'Cappellucci', 'Cope',
- 'DelRossi', 'Douglas', 'Fairweather',
- 'Foley', 'Frerking', 'Geiger',
- 'Ghinaudo', 'Horaz', 'Huffman',
- 'Hughes', 'Inman', 'Kokkonen',
- 'Larsen', 'Leier', 'Medlin',
- 'Milner', 'Phillips', 'Reisdorph',
- 'Roberts', 'Rogers', 'Rose',
- 'Salisbury', 'Trickey', 'Troxell',
- 'Turner', 'Warner', 'Welch');
-
- var
- i : integer;
- HashTable : ThtHashTableLinear;
-
- begin
- HashTable := ThtHashTableLinear.Create(47, CalcELFHash);
- try
- {add all employee names}
- for i := 0 to 32 do begin
- HashTable.Insert(TPEmployees[i], nil);
- HashTable.debugPrint(Format('tstHsh%d.LOG', [i]), false);
- end;
- HashTable.debugPrint('tstHshXX.LOG', true);
- {delete all but 6 employee names}
- for i := 6 to 32 do begin
- HashTable.Delete(TPEmployees[i]);
- HashTable.debugPrint(Format('tstHsh%d.LOG', [50+i]), false);
- end;
- HashTable.debugPrint('tstHshYY.LOG', true);
- finally
- HashTable.Free;
- end;
- end.
-